package com.szp.lagou.mq.rocketmq.consumer;

import com.szp.lagou.mq.rocketmq.constant.Constants;
import com.szp.lagou.mq.rocketmq.pojo.Order;
import com.szp.lagou.mq.rocketmq.service.OrderService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = Constants.KILL_ORDER_TOPIC, consumerGroup = "order-mq-group")
public class OrderConsumer implements RocketMQListener<Order> {
    @Autowired
    private OrderService orderService;

    @Override
    public void onMessage(Order order) {
        System.out.println(order);
        orderService.saveOrder(order);
    }
}
